package com.itheima.d5_map;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Set;

/*
     目标：掌握Map集合的常用方法(重点)
        public V put(K key,V value)	添加元素
        public int size()	获取集合的大小
        public void clear()	清空集合
        public boolean isEmpty()	判断集合是否为空，为空返回true , 反之
        public V get(Object key)	根据键获取对应值
        public V remove(Object key)	根据键删除整个元素
        public  boolean containsKey(Object key)	判断是否包含某个键
        public boolean containsValue(Object value)	判断是否包含某个值
        public Set<K> keySet()	获取全部键的集合
        public Collection<V> values()	获取Map集合的全部值
 */
public class MapTest2 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        System.out.println(map.put("吕布", "貂蝉"));
        map.put("周瑜","小乔");
        map.put("诸葛亮","黄月英");
        map.put("刘备","孙尚香");
        map.put("孙策","大乔");
        System.out.println(map);
        System.out.println(map.size());
//        map.clear();
        System.out.println(map.isEmpty());
        System.out.println(map.get("吕布"));
        System.out.println(map.remove("吕布"));
        System.out.println(map.containsKey("吕布"));
        System.out.println(map.containsValue("小乔"));
        Set<String> mapKeys = map.keySet();
        System.out.println(mapKeys);

        Collection<String> mapValues=map.values();
        System.out.println(mapValues);
        System.out.println(map);
    }
}
